const std = @import("std");
const awtk = @import("awtk");
const config = awtk.config;
const mvvm = @import("mvvm.zig");
const app = @import("application.zig");
const object = @import("object.zig");

const c = awtk.c;

pub const std_options = std.Options{
    .log_level = .debug,
};

pub fn main() !u8 {
    std.log.info("zig app: {s}", .{config.app_name});
    var gpa: std.heap.DebugAllocator(.{
        .stack_trace_frames = 8,
        .resize_stack_traces = true,
    }) = .init;
    defer if (gpa.deinit() != .ok) {
        std.log.err("memory leak!", .{});
    };

    try awtk.init(gpa.allocator());
    defer awtk.deinit();

    try mvvm.init();
    defer mvvm.deinit();

    try app.init();
    defer app.deinit();

    return awtk.run();
}

test {
    _ = object;
    _ = mvvm;
    _ = @import("models/user.zig");
}

test "@field C type" {
    const a = "button";
    const Widget = @field(c, a ++ "_t");
    try std.testing.expectEqual(Widget, c.button_t);
}
